#include <iostream>
#include <string.h>
using namespace std;
char s1[1000010], s2[1000010];
int ne[1000010] = { 0 };
int main()
{
    cin >> s1 + 1 >> s2 + 1;
    int len1 = strlen(s1+1);
    int len2 = strlen(s2+1);
    for (int i = 2, j = 0; i <= len2; i++)
    {
        while (j && s2[j + 1] != s2[i]) j = ne[j];
        if (s2[j + 1] == s2[i])
        {
            j++;
            ne[i] = j;
        }
    }
    for (int i = 1, j = 0; i <=len1; i++)
    {
        while (j && s2[j + 1] != s1[i]) j = ne[j];
        if (s2[j + 1] == s1[i])
        {
            j++;
            if (j == len2)
            {
                cout << i - len2 + 1 << endl;
            }

        }
    }
    for (int i = 1; i <= len2; i++)
    {
        cout << ne[i] << ' ';
    }
    return 0;
}


